// function setDisable(userId) {
//     xhExtra.ajaxRequest('customer/saveBind', {ids: [userId], target: 'disable'}, {}, function(result) {
//         window.location.reload();
//     });
// }


function setContact(userId){
    xhExtra.ajaxRequest('coop/saveBind', {iCCId: xhTool.getQuery('iCCId'), userId: userId}, {}, function(result) {
        window.location.reload();
        window.top.xhTop.getActiveFrame()['tabFrame']['contactFrame'].obj.dataGrid.reload();
    });
}

function disContact(userId) {
    xhExtra.ajaxRequest('coop/saveBind/true', {iCCId: xhTool.getQuery('iCCId'), userId: userId}, {}, function(result) {
        window.location.reload();
        window.top.xhTop.getActiveFrame()['tabFrame']['contactFrame'].obj.dataGrid.reload();
    });
}

$(function () {
    var sName = unescape(xhTool.getQuery('sName'));
    var sPhoneNum = xhTool.getQuery('sPhoneNum');
    var iCCId     = xhTool.getQuery('iCCId');
    var createAccountDom = window.top.xhTop.getModalConfirmDom();
    createAccountDom.click(function () {
        window.top.swal({
            title: '你确定要创建账号？',
            text: '姓名为：'+sName+'，账号为：'+sPhoneNum+',默认密码为：123456',
            type: 'warning',
            showCancelButton: true,
            confirmButtonText: '是的，我要创建',
            cancelButtonText: '不了，再考虑下',
        }).then(function() {
            xhExtra.ajaxRequest('coop/createAccount',{userName:sName,phoneNum:sPhoneNum,iCCId:iCCId},{},function (result) {
                xhExtra.setBtnNormal(createAccountDom);
                if(result.code==200){
                    window.top.swal(
                        '创建成功',
                        '',
                        'success'
                    );
                    window.location.reload();
                }
            });
        },function (dismiss) {
            xhExtra.setBtnNormal(createAccountDom);
            if(dismiss=='cancel'){
                return false;
            }
        });
    });
});